<?php
namespace bxd\core\controller;

/**
 * The MIT License
 *
 * Copyright (c) <year> <copyright holders>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @author Damiano Ciarla
 * @package core
 * @subpackage exception
 */
class ExceptionController extends \Exception
{
	/**
	 * Il metodo del controller non esiste
	 */
	const METHOD_NOT_EXISTS = 1;

	/**
	 * Il file del controller non esiste
	 */
	const FILE_NOT_EXISTS = 2;

	/**
	 * Il nome del controller non è corretto
	 */
	const INCORRECT_CLASS_NAME = 3;

	/**
	 * Il controller non estende la classe corretta
	 */
	const CONTROLLER_FILES_NOT_EXTENDS_THE_CORRECT_CLASS = 4;

	/**
	 * Il controller non estende la classe corretta
	 */
	const VIEW_NOT_EXISTS = 5;

	public function __construct($params, $code)
	{
		switch($code)
		{
			case self::METHOD_NOT_EXISTS :
				$message = sprintf("'" . $params[0] . "' method not exists in the '" . $params[1] . "' controller");
				break;

			case self::FILE_NOT_EXISTS :
				$message = sprintf("'" . $params[0] . "'.php file not exists in the '" . $params[1] . "' folder");
				break;

			case self::INCORRECT_CLASS_NAME :
				$message = sprintf("'" . $params . "' has not a valid name for the controller");
				break;

			case self::CONTROLLER_FILES_NOT_EXTENDS_THE_CORRECT_CLASS :
				$message = sprintf("'" . $params . "' controller not extends the 'Controller' abstract class");
				break;

			case self::VIEW_NOT_EXISTS :
				$message = sprintf("The view '" . $params . "' not exists");
				break;
		}

		parent::__construct($message, $code);
	}
}
?>